#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int a[110];
int main()
{
	int n;
	cin>>n;
	int num1 = 0;
	int num0 = 0;
	a[0] = 0;
	for(int i = 1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(x) num1++;
		else num0++;
		a[i] = num0-num1;
	}
	int maxn = 0;
	int x,y;
	for(int i = 1;i<=n;i++)
	{
		for(int j = i;j<=n;j++)
		{
			if(maxn<(a[j]-a[i-1]))
			{
				maxn = a[j]-a[i-1];
				x = i;
				y = j;
			//	printf("%d\n",maxn);
			}
		}
	}
	if(maxn==0) cout<<num1-1<<endl;
	else cout<<maxn+num1<<endl;
} 
